package com.geng.sample.test;

import com.geng.sample.GoodBye;
import com.geng.sample.HelloService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author geng
 */
public class Consumer {

    private static final Logger logger = LoggerFactory.getLogger(Consumer.class);

    public static void main(String[] args) throws Exception {

        //引入远程服务
        final ApplicationContext context = new ClassPathXmlApplicationContext("client.xml");



        testDC(context);

        testZK(context);


        System.in.read();
        //System.exit(1);
    }

    public static void testDC(ApplicationContext context){
        HelloService helloService = (HelloService)context.getBean("remoteHelloService");
        String result = helloService.sayHello("geng");
        String result2 = helloService.sayHelloAnother("jiabo");
        System.out.println(result);
        System.out.println(result2);
    }

    public static void testZK(ApplicationContext context){
        GoodBye byeService = (GoodBye)context.getBean("remoteByeService");
        System.out.println(byeService.sayGoodBye("提供者，再见"));
    }


}
